<?xml version='1.0'?>
<!--=======================================================================
	Copyright:	umlungu consulting (pty) ltd
	Author:		Alan Benington
	Started:	2008-06-14
	Status:		release	
	Version:	2.0.0
	Build:		20080614
	License:	GNU General Public License
	======================================================================= -->

<!--=======================================================================
	Development Notes:
	==================
	20080614:	Initial release.
	=======================================================================	-->

<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>

<!--=======================
	Match templates section
	======================= -->
	<xsl:template match="page/profiles">
		<xsl:variable name="max" select="count(profile)"/>
		<div id="profiles">
			<xsl:call-template name="Profiles"/>
			<div class="profile" id="prf_def">
				<img class="profile" src="images/who.jpg" width="170px" height="210px"/>
				<div class="profile-txt">
					<xsl:apply-templates select="title"/>
					<xsl:for-each select="profile">
						<input type="radio" id="prfs" name="profiles">
							<xsl:attribute name="onclick">
								<xsl:text>javascript:insight.FstProfile('prf_def', 'prf_lst', '</xsl:text>
								<xsl:value-of select="parent::*/fld/@name"/>
								<xsl:text>', this.value, 'prf_', </xsl:text>
								<xsl:value-of select="position()"/><xsl:text>, </xsl:text>
								<xsl:value-of select="$max"/><xsl:text>, 'prf_img', 'profile')</xsl:text>
							</xsl:attribute>
							<xsl:attribute name="value">
								<xsl:value-of select="@id"/>
							</xsl:attribute>
							
							<span class="prf-hd"><xsl:value-of select="line"/></span>
							<xsl:text> - </xsl:text>
							<xsl:value-of select="byline"/>
						</input><br/>
					</xsl:for-each>
				</div>
			</div>
		</div>
		<form method="post" id="profile-frm">
			<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
			<xsl:attribute name="onkeypress">
				<xsl:text>x_form.KeyPress(this)</xsl:text>
			</xsl:attribute>
			<xsl:attribute name="action">
				<xsl:apply-templates select="action" />
			</xsl:attribute>
			<xsl:apply-templates select="fld" />
			<xsl:call-template name="FormButton">
				<xsl:with-param name="label">That's me!</xsl:with-param>
				<xsl:with-param name="type">next</xsl:with-param>
				<xsl:with-param name="formname"><xsl:value-of select="@name"/></xsl:with-param>
			</xsl:call-template>
		</form>
		<xsl:call-template name="ProfileImages"/>
	</xsl:template>
		
	<xsl:template match="page/profiles/fld">
		<xsl:call-template name="Input"/>
	</xsl:template>
		
	<xsl:template match="page/profiles/title">
		<h4><xsl:apply-templates/></h4>
	</xsl:template>
		
	<xsl:template match="page/profiles/profile">
		<div class="profile-des">
			<xsl:attribute name="id">
				<xsl:text>prf_</xsl:text>
				<xsl:value-of select="position()"/>
			</xsl:attribute>
			<xsl:apply-templates select="line"/>
			<xsl:apply-templates select="byline"/>
			<xsl:apply-templates select="para"/>
		</div>
	</xsl:template>
		
	<xsl:template match="page/profiles/profile/line">
		<h5><xsl:apply-templates/></h5>
	</xsl:template>
		
	<xsl:template match="page/profiles/profile/byline">
		<h6><xsl:apply-templates/></h6>
	</xsl:template>
		
	<xsl:template match="page/profiles/profile/para">
		<div class="profile-para"><xsl:apply-templates/></div>
	</xsl:template>
		
<!--=======================
	Named templates section
	======================= -->

	<xsl:template name="Profiles">
		<xsl:variable name="max" select="count(profile)"/>
		<div class="profile" id="prf_lst">
			<img id="prf_img" class="profile" src="who.jpg" width="170px" height="210px">
			</img>
			<div class="profile-lst">
				<xsl:for-each select="profile">
					<div class="lst-item">
						<input type="radio" id="prf" name="Profile">
							<xsl:attribute name="onclick">
								<xsl:text>javascript:insight.SetProfile('</xsl:text>
								<xsl:value-of select="parent::*/fld/@name"/>
								<xsl:text>', this.value, 'prf_', </xsl:text>
								<xsl:value-of select="position()"/><xsl:text>, </xsl:text>
								<xsl:value-of select="$max"/><xsl:text>, 'prf_img')</xsl:text>
							</xsl:attribute>
							<xsl:attribute name="value">
								<xsl:value-of select="@id"/>
							</xsl:attribute>
							<xsl:value-of select="line"/>
						</input>
						<!--
						<a>
							<xsl:attribute name="href">
								<xsl:text>javascript:x_form.SetRadio('profile', '</xsl:text>
								<xsl:value-of select="@id"/><xsl:text>');</xsl:text>
								<xsl:text>x_form.SetValue('</xsl:text>
								<xsl:value-of select="parent::*/fld/@name"/>
								<xsl:text>', '</xsl:text><xsl:value-of select="@id"/><xsl:text>')</xsl:text>
							</xsl:attribute>
							<xsl:value-of select="line"/>
						</a>
						-->
					</div>
				</xsl:for-each>
			</div>
			<xsl:apply-templates select="profile"/>
		</div>
	</xsl:template>
	
	<xsl:template name="ProfileImages">
		<xsl:for-each select="profile">
			<img class="profile-img" width="170px" height="210px">
				<xsl:attribute name="src">
					<xsl:text>images/</xsl:text>
					<xsl:value-of select="@id"/>
					<xsl:text>.gif</xsl:text>
				</xsl:attribute>
			</img>
		</xsl:for-each>
	</xsl:template>
	
<!--=========================
	Utility templates section
	========================= -->
	
</xsl:stylesheet>

